#include "Inc/rlc.h"

uint    cnt= 0;
ulong   count0= 0, count1= 0, res= 0;
double  length= 0.0; 

void PCA_isr() interrupt 7 using 1
{
    if (CCF0)
    {
        CCF0 = 0;
        if (CF && ((CCAP0H & 0x80) == 0))
        {
            CF = 0;
            cnt++;
        }
        count0 = count1;          
        ((uchar *)&count1)[3] = CCAP0L;  
        ((uchar *)&count1)[2] = CCAP0H;
        ((uint *)&count1)[0] = cnt;
        res = (count1 - count0);   
        //((BYTE *)&length)[0] = 0;
        
        length = (double)res * 1.0;
    }
    if (CF)
    {
        CF = 0;
        cnt++;                      //PCA overflows
    }
}

